# -*- coding: utf-8 -*-

from w.html.base import DocType, Tag, SingleTag, TAG

class HTML401DocType(DocType):
    docTypeTemplate = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 %s//EN\" \"http://www.w3.org/TR/html4/%s">"""

class HTML401Tag(Tag):
    fString = '<%(tag)s %%s>%%s</%(tag)s>'%{'tag':Tag._name}

    def renderOpenedTag(self,s):
        return '<%s>'%s

    def renderClosedTag(self,s):
        return '</%s>'%s

    def unformatted(self, content=None):
        content = ''.join(str(e) for e in self.make()) if not content else content
        return '<%s %s>%s</%s>'%(self._name, self.generateArgsString(), content, self._name)

class HTML401SingleTag(SingleTag):
    def renderTag(self,s):
        return '<%s>'%s

    def unformatted(self):
        return '<%s %s>' % (self._name, self.generateArgsString())
